'use strict';function _Gh(e,f){return _ow({mouse:"Mouse",window:"Window",screen:"Screen"},e.position,"position","",f)}function _zk(e,f){return`${_ow({[_S]:"Left",[_6k]:"Center",[_gd]:"Right"},e.alignHorz,"alignHorz","number",f)}\n ${_ow({[_Io]:"Top",[_ei]:"Middle",[_Zd]:"Bottom"},e.alignVert,"alignVert","number",f)}`}function _lu(e){return _bg("menuStyle","style",e.style,"&nbsp;",!0,!1)}
let _Nj=()=>{function e(a,d=!1){"custom"==a.type==_Mg(a.content)&&a.content||(a.content="custom"==a.type?[]:"");let b=a.rootOptions||{};return _Bj(_lo)`\n <tree value={} type=${a.type} ${a.subMenu?"subMenu":""}>\n <parent>\n <ln></ln>\n <item>\n Type: ${_Qp({TSE:["Tab list","tse"],closedTabs:["Closed tab list","ses",,"perms=ses"],bmFolder:["Bookmark folder","bmF",,"perms=bkm"],action:["Action","act"],switch:["Switch","swt"],custom:["Submenu","cus"]},"type",a.type,"","helpCtx")}\n ${({TSE:()=>_bg("tse",
"content",a.content,...[,,,,],"multi"),closedTabs:()=>`<input type=text name=title value="${a.title||""}" placeholder="Enter a caption..." autocomplete=off>`,bmFolder:()=>_Hy("content",a.content,!0),action:()=>n(a.content),switch:()=>_Ee("content",a.content),custom:()=>`<input type=text name=title value="${a.title||""}" placeholder="Enter a caption..." autocomplete=off>`})[a.type]()}\n <controls>\n <button>Options</button>\n <z actions>\n <move><u title="Move up"></u><d title="Move down"></d></move>\n <del button title="Delete"></del>\n </z>\n </controls>\n </item>\n </parent>\n ${_Mg(a.content)?
_Bj`\n <children name=content value=[]>\n ${a.content.map(c=>e(c))}<parent><ln></ln><add>Add item... <h h=add></h></add></parent>\n </children>\n `:""}\n <optPane popupCntr>${f(a,d)}</optPane>\n ${d?`\n <rootOptions name=rootOptions value={}>\n <div>Menu position: ${_Gh(b)} <h h=pos></h></div>\n <div>Alignment: ${_zk(b)} <h h=alg></h></div> <br>\n <div>Menu system: ${_ow({std:"Standard",simple:"Simple"},b.menuSystem,"menuSystem")} <h h=sys></h></div>\n <div><button>Base options</button> <h h=opt></h></div>\n </rootOptions>\n `:
""}\n </tree>\n `}function f(a,d=!1){let b=a.commonOptions||{},c=_Kg(b.itemsDistrib,0)||"";return _Bj`\n ${d?"":`\n <div>\n <label>${_io("break",a.break)}New row/col</label> <h h=brk></h> &nbsp;\n <label>${_io("sepLine",a.sepLine)}Separator line</label> <h h=sep></h>\n </div>\n `}\n ${a.type.in("custom","action","switch")?"":`\n <div><label>${_io("subMenu",a.subMenu)}Show as submenu</label></div>\n `}\n ${a.type.in("action","switch")?"":_Bj`\n <co name=commonOptions value={}>\n <div><l>Layout:</l> ${_ow([["",
""],[_or("R"),"Rows"],[_or("C"),"Columns"]],b.layout,"layout","number")} <h h=lay></h></div>\n <div name=itemsDistrib value=[]>\n <l>Grouping:</l> ${_ow({"":"",numGroups:"Num. of groups",perGroup:"Items per group",auto:"Automatic"},c,"")}\n <input type=number value="${_Kg(b.itemsDistrib,1)||""}" min=1 ${c&&"auto"!=c?"":"greyedout"}>\n <h h=grp></h>\n </div>\n <div><l>Group align:</l> ${_ow([["",""],[0,"Left/Top"],[1,"Center"]],b.centerGroups,"centerGroups","bool hard")} <h h=cGrp></h></div>\n <div><l>Max items:</l> <input type=number name=maxItems min=1 value="${b.maxItems}"> <h h=max></h></div>\n <div><l>Item names:</l> ${_ow([["",
""],[0,"Visible"],[1,"Hidden"]],b.noTitles,"noTitles","bool hard")} <h h=tit></h></div>\n ${a.type.in("bmFolder")?"":`\n <div><l>Thumbnails:</l> ${_ow([["",""],[0,"Hidden"],[_9f,"Small"],[_Dk,"Medium"],[_8r,"Large"],[_Ah,"Extra large"]],null!=b.withPreviews?b.withPreviews?_Dk:0:b.thumbSize,"thumbSize","number")} <h h=prv></h></div>\n `}\n <div><l>Menu style:</l> ${_lu(b)} <h h=sty></h></div>\n </co>\n `}\n `}let l,h,n=(()=>{function a(b){return`<img src="${b.icon&&b.icon.img||"res/actionIcon.svg"}"><t>${b.title||
"(unnamed action)"}</t>`}function d(b){_qf("trigActList")(c=>{let k=$(b).attr("value");c=[...c].filter(([,g])=>!g.disabled&&g.title).sort(([,{title:g}],[,{title:m}])=>_bo(g,m)).map(([g,m])=>`<item value=${g} ${g==k?"selected":""}>${a(m)}</item>`).join("");c=$(_Bj`<namedActionMenu>${c||_ne("noNamedActions")}</namedActionMenu>`).on("click","item",function(){$(b).attr("value",$(this).attr("value")).html(this.innerHTML).triggerEvt("change",!0);$(this).triggerEvt("focusLost",!0)});_Jh(c,b,"btrl","borderAndShadowSimple noTail");
$("item[selected]",c).each(function(){this.scrollIntoViewIfNeeded(!0)})})}return function(b){let c=$('<customSelect name=content placeholder="Choose an action..."></customSelect>');l.push(new Promise(_Ii(function*(){h||(h=new Promise(_qf("trigActList")));let k=(yield h)[b];k&&c.attr("value",b).html(a(k))})));return c.on("mousedown",function(){d(this)})}})();return function(a){l=[];h=null;let d=_Bj(_lo)`\n <MenuSpecEditor helpCtx=/menuEditor>${e(a.value,!0)}<spacer></spacer></MenuSpecEditor>\n `.prop("onInitDone",
{asyncFunc:_uf(l)}).on("change","item > [name=type]",function(){let b=$(this).closest("tree");_rg(b)&&_dj(400);b.replaceWith(e(_To(b).del("content")))}).on("click","add",function(){e({type:"TSE"}).insertBefore($(this).closest("parent")).hide().show(200,()=>{61>_Ok?this.scrollIntoViewIfNeeded(!1):this.scrollIntoView({behavior:"smooth",block:"nearest"})});d.removeClass("empty").triggerEvt("change",!0)}).on("change","optPane [name=subMenu]",function(){$(this).closest("tree").attr("subMenu",this.checked?
"":null)}).on("change","optPane [name=itemsDistrib] select",function(){let b=$(this).closest("tree"),c=_To(b);$(this).closest("optPane").find("> :not(resizeDetector)").remove().end().prepend(f(c,!b.parent().is("children")))}).on("change",function(){a.value=_To($("> tree",d))}).on("dblclick","del",function(){$(this).closest("tree").css("visibility","hidden").hide(300,function(){_rg(this)&&_dj(400);this.remove();d.triggerEvt("change",!0)})}).on("mousedown","move > *",function(){_Lp($(this).closest("tree"),
"D"==this.tagName?1:-1);d.triggerEvt("change",!0)}).on("mousedown","controls > button, rootOptions button",function(){_Jh($(this).closest("tree").find("> optPane"),this,"btrl")}).captureTgtEvt("close","optPane",function(){$(this).hide()});_Pt(a.value.content)&&d.addClass("empty");return d}};
